require(["config"],function(){
	require(["jquery","template","header","carousel","footer" ], function($,template){
		//console.log( $(".jingdian img"));
		function Index(){
			console.log("开始加载index内容");
			// 加载轮播图
			this.loadCarousel();
			// 加载其他内容
			this.load();
			
		}
		// 合并，[tree,递归合并]，target[合并后的结果]，object1
		$.extend(Index.prototype, {
			//加载轮播图
			loadCarousel:function(){
				$(".main_image").carousel( {
					imgs : [
						{href:"#",src:"/images/index/01.jpg"},
						{href:"#",src:"/images/index/02.jpg"},
						{href:"#",src:"/images/index/03.jpg"},
					],
					width:996,
					height:445,
					duration:3000,
					color:["none","none"]
				});
			},
			
			// 页面内容
			load:function(){
				// 加载主页: 系列
				this.index_tree();
				
			},
			
			index_tree: function(){
				let html = "";
				$.ajax("http://rap2api.taobao.org/app/mock/86542/shop")
				 .done(function(data){
					 // 默认数据验证成功
					 var data = {shops : data.res_body.data };
					 // template 需要一个属性【数组？】，来传入做变量
					 data.shops.length = 3;

					 html = template("jingdian_template",data);
					 $(".index_tree").html(html);
				 } );
			}
		})
		
		// 实例
		new Index();
		//修改轮播图样式
		const _prev=$(".main_image .prev,.main_image .next"); //左右键
		_prev.css("height","45px");
		_prev.css("opacity","0.3");
		_prev.css("margin","auto 15px");
		_prev.css("line-height","36px");
		
		const _page = $(".main_image .pages");
		_page.css("background","none");
		_page.css("text-align","center");
		
		_pagei = $(".main_image .pages i");
		_pagei.css("margin","10px 3px");
	})
})